Skip to content

feat: add link input modal#122

Merged
wendyyuchensun merged 3 commits intocoseeing:mainfrom
wendyyuchensun:v2-6-link-input-modal
Apr 5, 2026
Merged

feat: add link input modal#122
wendyyuchensun merged 3 commits intocoseeing:mainfrom
wendyyuchensun:v2-6-link-input-modal

Conversation

@wendyyuchensun
Copy link
Copy Markdown
Collaborator

@wendyyuchensun wendyyuchensun commented Apr 5, 2026

Comment on lines +13 to +32
const resetForm = useCallback(() => {
setDisplay('');
setTitle('');
setUrl('');
setOpenInNewTab(true);
}, []);

const handleClose = useCallback(() => {
resetForm();
onClose();
}, [resetForm, onClose]);

const handleConfirm = useCallback(() => {
if (!display.trim() || !url.trim()) return;
const prefix = openInNewTab ? '@' : '';
const titlePart = title.trim() ? `[[${title.trim()}]]` : '';
const markdown = `${prefix}[${display.trim()}]${titlePart}(${url.trim()})`;
onConfirm(markdown);
handleClose();
}, [display, title, url, openInNewTab, onConfirm, handleClose]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這三個 function 好像不需要包 useCallback 嗎~?
就我所知好像以下情境比較需要:

  • 傳給 React.memo 包裝的子元件,避免不必要的 re-render
  • 作為其他 hook(如 useEffect)的依賴

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確實不需要,感謝提醒:e0c5b72

@wendyyuchensun wendyyuchensun force-pushed the v2-6-link-input-modal branch from e0c5b72 to 4dcd072 Compare April 5, 2026 14:30
@wendyyuchensun wendyyuchensun merged commit 5b7dba3 into coseeing:main Apr 5, 2026
1 check passed
@wendyyuchensun wendyyuchensun deleted the v2-6-link-input-modal branch April 5, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants